#include <QtGui>
#include "result.h"

Result::Result(QWidget *parent) : QTreeWidget(parent) {

  russianCodec = QTextCodec::codecForName("UTF-8");
  QTextCodec::setCodecForTr(russianCodec);
  QTextCodec::setCodecForCStrings(russianCodec);

//ВВОДИМЫЕ ДАННЫЕ
  this->setColumnCount(2);
  this->setColumnWidth(0, 100);

  item = new QTreeWidgetItem();
  item->setText(0, "Переменные");
  item->setTextAlignment(0, Qt::AlignHCenter | Qt::AlignVCenter);
  item->setText(1, "Значения");
  item->setTextAlignment(1, Qt::AlignHCenter | Qt::AlignVCenter);

  this->setHeaderItem(item);
  this->setFirstItemColumnSpanned(item, true);

  // this->horizontalHeader()->isEnabled(false);

  //Вешина ячейки
  int sizeVCell = 20;
  //Размер текста элементов
  int sizeText = 4;
  //Размер текста загловков
  int sizeTextHead = 3;
  //Размер обозначений
  int sizeSub = 5;

  //Цвет заголовка
  QColor clH0(121, 121, 121);
  //Цвет текста заголовка
  QColor cltextH0(230, 230, 230);
  //Цвет выделенной ячейки
  QColor clSelCell(173, 183, 200);

  //Цвет выводимых переменных
  QColor clT1(234, 232, 199);
  QColor clT2(215, 212, 172);

  //Текстура для заголовочного декоратора
  QBrush headBrush;
  headBrush.setTextureImage(QImage(":/resources/headBg.png"));

  palette.setColor(QPalette::Base, clT1);
  palette.setColor(QPalette::AlternateBase, clT2);
  palette.setColor(QPalette::Highlight, clSelCell);
  this->setPalette(palette);
  this->setAlternatingRowColors(true);

  //Отступ для переменных
  int indentVar = 10;
  //Отступ для значений
  int indentVal = 25;

  QString toolTip;

  QString strName;


//ЗАКЛАДКА ДЛЯ РАСХОДОВ ВОДЫ

//Qrain
  strName  = "<font size=";
  strName += QString().setNum(sizeText);
  strName += ">Q<sub><font size=";
  strName += QString().setNum(sizeSub);
  strName += ">rain</sub></font>";

  nameqRainCon = new QLabel();
  nameqRainCon->setOpenExternalLinks(false);
  nameqRainCon->setTextInteractionFlags(Qt::NoTextInteraction);
  nameqRainCon->setText(strName);
  nameqRainCon->setIndent(indentVar);

  labqRainCon = new QLabel(this);
  // labqRainCon->setAlignment(Qt::AlignHRight | Qt::AlignVCenter);
  labqRainCon->setIndent(indentVal);
  labqRainCon->setText("");
  setAddStrRainCon("");
  setqRainCon(0);

  itemqRainCon = new QTreeWidgetItem();
  itemqRainCon->setSizeHint(0, QSize(100, sizeVCell));

  toolTip = "Расход дождевых вод";

  itemqRainCon->setToolTip(0, toolTip);
  itemqRainCon->setToolTip(1, toolTip);

//Qr
  strName  = "<font size=";
  strName += QString().setNum(sizeText);
  strName += ">Q<sub><font size=";
  strName += QString().setNum(sizeSub);
  strName += ">r</sub></font>";

  nameQr = new QLabel();
  nameQr->setOpenExternalLinks(false);
  nameQr->setTextInteractionFlags(Qt::NoTextInteraction);
  nameQr->setText(strName);
  nameQr->setIndent(indentVar);

  labQr = new QLabel(this);
  labQr->setText("");
//   labQr->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
  labQr->setIndent(indentVal);
  setQr(0);
  setAddStrQr("");

  itemQr = new QTreeWidgetItem();
  itemQr->setSizeHint(0, QSize(100, sizeVCell));

  toolTip = "Расчетное наполнение";

  itemQr->setToolTip(0, toolTip);
  itemQr->setToolTip(1, toolTip);

//Qcr
  strName  = "<font size=";
  strName += QString().setNum(sizeText);
  strName += ">Q<sub><font size=";
  strName += QString().setNum(sizeSub);
  strName += ">cr</sub></font>";

  nameQcr = new QLabel();
  nameQcr->setOpenExternalLinks(false);
  nameQcr->setTextInteractionFlags(Qt::NoTextInteraction);
  nameQcr->setText(strName);
  nameQcr->setIndent(indentVar);

  labQcr = new QLabel(this);
  labQcr->setText("");
  labQcr->setIndent(indentVal);
  setQcr(0);
  setAddStrQcr("");

  itemQcr = new QTreeWidgetItem();
  itemQcr->setSizeHint(0, QSize(100, sizeVCell));

  toolTip = "Критическое наполнение";

  itemQcr->setToolTip(0, toolTip);
  itemQcr->setToolTip(1, toolTip);

//Qcr
  strName  = "<font size=";
  strName += QString().setNum(sizeText);
  strName += ">Q<sub><font size=";
  strName += QString().setNum(sizeSub);
  strName += ">rec</sub></font>";

  nameQrec = new QLabel();
  nameQrec->setOpenExternalLinks(false);
  nameQrec->setTextInteractionFlags(Qt::NoTextInteraction);
  nameQrec->setText(strName);
  nameQrec->setIndent(indentVar);

  labQrec = new QLabel(this);
  labQrec->setText("");
  labQrec->setIndent(indentVal);
  setQrec(0);
  setAddStrQrec("");

  itemQrec = new QTreeWidgetItem();
  itemQrec->setSizeHint(0, QSize(100, sizeVCell));

  toolTip = "Рекомендуемое наполнение";

  itemQrec->setToolTip(0, toolTip);
  itemQrec->setToolTip(1, toolTip);


//Заголовок для расходов воды
  strName  = "<font color=#E0E0E0 size=";
  strName += QString().setNum(sizeTextHead);
  strName += "><b>Расход воды</b></font>";

  nameQs = new QLabel();
  nameQs->setOpenExternalLinks(false);
  nameQs->setTextInteractionFlags(Qt::NoTextInteraction);
  nameQs->setText(strName);
  nameQs->setIndent(indentVar);

  itemQs = new QTreeWidgetItem();
  itemQs->setSizeHint(0, QSize(100, sizeVCell));
  itemQs->setBackground(0, headBrush);

  itemQs->addChild(itemqRainCon);
  itemQs->addChild(itemQr);
  itemQs->addChild(itemQcr);
  itemQs->addChild(itemQrec);

  this->addTopLevelItem(itemQs);
  this->setItemWidget(itemQs, 0, nameQs);
  this->setFirstItemColumnSpanned(itemQs, true);

  this->setItemWidget(itemqRainCon, 0, nameqRainCon);
  this->setItemWidget(itemqRainCon, 1, labqRainCon);

  this->setItemWidget(itemQr, 0, nameQr);
  this->setItemWidget(itemQr, 1, labQr);

  this->setItemWidget(itemQcr, 0, nameQcr);
  this->setItemWidget(itemQcr, 1, labQcr);

  this->setItemWidget(itemQrec, 0, nameQrec);
  this->setItemWidget(itemQrec, 1, labQrec);

  itemQs->setExpanded(true);


//ЗАКЛАДКА ДЛЯ ВЫСОТ

//hrain
  strName  = "<font size=";
  strName += QString().setNum(sizeText);
  strName += ">h<sub><font size=";
  strName += QString().setNum(sizeSub);
  strName += ">rain</sub></font>";

  nameHrain = new QLabel();
  nameHrain->setOpenExternalLinks(false);
  nameHrain->setTextInteractionFlags(Qt::NoTextInteraction);
  nameHrain->setText(strName);
  nameHrain->setIndent(indentVar);

  labHrain = new QLabel(this);
  // labqRainCon->setAlignment(Qt::AlignHRight | Qt::AlignVCenter);
  labHrain->setIndent(indentVal);
  labHrain->setText("");
  setAddStrHrain("");
  setHrain(0);

  itemHrain = new QTreeWidgetItem();
  itemHrain->setSizeHint(0, QSize(100, sizeVCell));

  toolTip = "Высота наполнения дождевой водой";

  itemHrain->setToolTip(0, toolTip);
  itemHrain->setToolTip(1, toolTip);

//hcr
  strName  = "<font size=";
  strName += QString().setNum(sizeText);
  strName += ">h<sub><font size=";
  strName += QString().setNum(sizeSub);
  strName += ">cr</sub></font>";

  nameHcr = new QLabel();
  nameHcr->setOpenExternalLinks(false);
  nameHcr->setTextInteractionFlags(Qt::NoTextInteraction);
  nameHcr->setText(strName);
  nameHcr->setIndent(indentVar);

  labHcr = new QLabel(this);
  labHcr->setText("");
//   labHcr->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
  labHcr->setIndent(indentVal);
  setHcr(0);
  setAddStrHcr("");

  itemHcr = new QTreeWidgetItem();
  itemHcr->setSizeHint(0, QSize(100, sizeVCell));

  toolTip = "Критическая высота наполнения";

  itemHcr->setToolTip(0, toolTip);
  itemHcr->setToolTip(1, toolTip);

//hrec
  strName  = "<font size=";
  strName += QString().setNum(sizeText);
  strName += ">h<sub><font size=";
  strName += QString().setNum(sizeSub);
  strName += ">rec</sub></font>";

  nameHrec = new QLabel();
  nameHrec->setOpenExternalLinks(false);
  nameHrec->setTextInteractionFlags(Qt::NoTextInteraction);
  nameHrec->setText(strName);
  nameHrec->setIndent(indentVar);

  labHrec = new QLabel(this);
  labHrec->setText("");
  labHrec->setIndent(indentVal);
  setHrec(0);
  setAddStrHrec("");

  itemHrec = new QTreeWidgetItem();
  itemHrec->setSizeHint(0, QSize(100, sizeVCell));

  toolTip = "Рекомендуемая высота наполнения";

  itemHrec->setToolTip(0, toolTip);
  itemHrec->setToolTip(1, toolTip);

//Заголовок для высот
  strName  = "<font color=#E0E0E0 size=";
  strName += QString().setNum(sizeTextHead);
  strName += "><b>Высота</b></font>";

  nameHs = new QLabel();
  nameHs->setOpenExternalLinks(false);
  nameHs->setTextInteractionFlags(Qt::NoTextInteraction);
  nameHs->setText(strName);
  nameHs->setIndent(indentVar);

  itemHs = new QTreeWidgetItem();
  itemHs->setSizeHint(0, QSize(100, sizeVCell));
  itemHs->setBackground(0, headBrush);

  itemHs->addChild(itemHrain);
  itemHs->addChild(itemHcr);
  itemHs->addChild(itemHrec);

  this->addTopLevelItem(itemHs);
  this->setItemWidget(itemHs, 0, nameHs);
  this->setFirstItemColumnSpanned(itemHs, true);

  this->setItemWidget(itemHrain, 0, nameHrain);
  this->setItemWidget(itemHrain, 1, labHrain);

  this->setItemWidget(itemHcr, 0, nameHcr);
  this->setItemWidget(itemHcr, 1, labHcr);

  this->setItemWidget(itemHrec, 0, nameHrec);
  this->setItemWidget(itemHrec, 1, labHrec);

  itemHs->setExpanded(true);

//ВЫЧИСЛЕНИЯ ДЛЯ ЛОТКА

//icr
  strName  = "<font size=";
  strName += QString().setNum(sizeText);
  strName += ">i<sub><font size=";
  strName += QString().setNum(sizeSub);
  strName += ">cr</sub></font>";

  nameIcr = new QLabel();
  nameIcr->setOpenExternalLinks(false);
  nameIcr->setTextInteractionFlags(Qt::NoTextInteraction);
  nameIcr->setText(strName);
  nameIcr->setIndent(indentVar);

  labIcr = new QLabel(this);
  labIcr->setText("");
//   labIcr->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
  labIcr->setIndent(indentVal);
  setIcr(0);
  setAddStrIcr("");

  itemIcr = new QTreeWidgetItem();
  itemIcr->setSizeHint(0, QSize(100, sizeVCell));

  toolTip = "Критический уклон";

  itemIcr->setToolTip(0, toolTip);
  itemIcr->setToolTip(1, toolTip);

//S
  strName  = "<font size=";
  strName += QString().setNum(sizeText);
  strName += ">S</font>";

  nameArea = new QLabel();
  nameArea->setOpenExternalLinks(false);
  nameArea->setTextInteractionFlags(Qt::NoTextInteraction);
  nameArea->setText(strName);
  nameArea->setIndent(indentVar);

  labArea = new QLabel(this);
  labArea->setText("");
//   labArea->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
  labArea->setIndent(indentVal);
  setArea(0);
  setAddStrArea("");

  itemArea = new QTreeWidgetItem();
  itemArea->setSizeHint(0, QSize(100, sizeVCell));

  toolTip = "Площадь живого сечения";

  itemArea->setToolTip(0, toolTip);
  itemArea->setToolTip(1, toolTip);

//X
  strName  = "<font size=";
  strName += QString().setNum(sizeText);
  strName += ">X</font>";

  namePerimeter = new QLabel();
  namePerimeter->setOpenExternalLinks(false);
  namePerimeter->setTextInteractionFlags(Qt::NoTextInteraction);
  namePerimeter->setText(strName);
  namePerimeter->setIndent(indentVar);

  labPerimeter = new QLabel(this);
  labPerimeter->setText("");
//   labPerimeter->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
  labPerimeter->setIndent(indentVal);
  setPerimeter(0);
  setAddStrPerimeter("");

  itemPerimeter = new QTreeWidgetItem();
  itemPerimeter->setSizeHint(0, QSize(100, sizeVCell));

  toolTip = "Смоченный периметр";

  itemPerimeter->setToolTip(0, toolTip);
  itemPerimeter->setToolTip(1, toolTip);

//R
  strName  = "<font size=";
  strName += QString().setNum(sizeText);
  strName += ">R</font>";

  nameRadius = new QLabel();
  nameRadius->setOpenExternalLinks(false);
  nameRadius->setTextInteractionFlags(Qt::NoTextInteraction);
  nameRadius->setText(strName);
  nameRadius->setIndent(indentVar);

  labRadius = new QLabel(this);
  labRadius->setText("");
//   labRadius->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
  labRadius->setIndent(indentVal);
  setRadius(0);
  setAddStrRadius("");

  itemRadius = new QTreeWidgetItem();
  itemRadius->setSizeHint(0, QSize(100, sizeVCell));

  toolTip = "Гидравлический радиус";

  itemRadius->setToolTip(0, toolTip);
  itemRadius->setToolTip(1, toolTip);

//C
  strName  = "<font size=";
  strName += QString().setNum(sizeText);
  strName += ">C</font>";

  nameShezy = new QLabel();
  nameShezy->setOpenExternalLinks(false);
  nameShezy->setTextInteractionFlags(Qt::NoTextInteraction);
  nameShezy->setText(strName);
  nameShezy->setIndent(indentVar);

  labShezy = new QLabel(this);
  labShezy->setText("");
//   labShezy->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
  labShezy->setIndent(indentVal);
  setShezy(0);
  setAddStrShezy("");

  itemShezy = new QTreeWidgetItem();
  itemShezy->setSizeHint(0, QSize(100, sizeVCell));

  toolTip = "Коэффициент Шези";

  itemShezy->setToolTip(0, toolTip);
  itemShezy->setToolTip(1, toolTip);

//A
  strName  = "<font size=";
  strName += QString().setNum(sizeText);
  strName += ">A</font></sub></font>";

  nameAQ = new QLabel();
  nameAQ->setOpenExternalLinks(false);
  nameAQ->setTextInteractionFlags(Qt::NoTextInteraction);
  nameAQ->setText(strName);
  nameAQ->setIndent(indentVar);

  labAQ = new QLabel(this);
  labAQ->setText("");
//   labAQ->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
  labAQ->setIndent(indentVal);
  setAQ(0);
  setAddStrAQ("");

  itemAQ = new QTreeWidgetItem();
  itemAQ->setSizeHint(0, QSize(100, sizeVCell));

  toolTip = "интенсивность  дождя, соответствующая его продолжительности t = 0";

  itemAQ->setToolTip(0, toolTip);
  itemAQ->setToolTip(1, toolTip);

//Заголовок для вычислений лотка
  strName  = "<font color=#E0E0E0 size=";
  strName += QString().setNum(sizeTextHead);
  strName += "><b>Параметры канала</b></font>";

  nameResTray = new QLabel();
  nameResTray->setOpenExternalLinks(false);
  nameResTray->setTextInteractionFlags(Qt::NoTextInteraction);
  nameResTray->setText(strName);
  nameResTray->setIndent(indentVar);

  itemResTray = new QTreeWidgetItem();
  itemResTray->setSizeHint(0, QSize(100, sizeVCell));
  itemResTray->setBackground(0, headBrush);
//   itemResTray->setBackground(0, clH0);

  itemResTray->addChild(itemIcr);
  // itemResTray->addChild(itemHcr);
  // itemResTray->addChild(itemQr);
  itemResTray->addChild(itemArea);
  itemResTray->addChild(itemPerimeter);
  itemResTray->addChild(itemRadius);
  itemResTray->addChild(itemShezy);
  itemResTray->addChild(itemAQ);

  this->addTopLevelItem(itemResTray);
  this->setItemWidget(itemResTray, 0, nameResTray);
  this->setFirstItemColumnSpanned(itemResTray, true);


  this->setItemWidget(itemIcr, 0, nameIcr);
  this->setItemWidget(itemIcr, 1, labIcr);

  // this->setItemWidget(itemHcr, 0, nameHcr);
  // this->setItemWidget(itemHcr, 1, labHcr);

  // this->setItemWidget(itemQr, 0, nameQr);
  // this->setItemWidget(itemQr, 1, labQr);

  this->setItemWidget(itemArea, 0, nameArea);
  this->setItemWidget(itemArea, 1, labArea);

  this->setItemWidget(itemPerimeter, 0, namePerimeter);
  this->setItemWidget(itemPerimeter, 1, labPerimeter);

  this->setItemWidget(itemRadius, 0, nameRadius);
  this->setItemWidget(itemRadius, 1, labRadius);

  this->setItemWidget(itemShezy, 0, nameShezy);
  this->setItemWidget(itemShezy, 1, labShezy);

  this->setItemWidget(itemAQ, 0, nameAQ);
  this->setItemWidget(itemAQ, 1, labAQ);

  itemResTray->setExpanded(true);

//РАСЧЕТ СКОРОСТЕЙ

//vs
  strName  = "<font size=";
  strName += QString().setNum(sizeText);
  strName += ">v<sub><font size=";
  strName += QString().setNum(sizeSub);
  strName += ">s</sub></font>";

  nameVs = new QLabel();
  nameVs->setOpenExternalLinks(false);
  nameVs->setTextInteractionFlags(Qt::NoTextInteraction);
  nameVs->setText(strName);
  nameVs->setIndent(indentVar);

  labVs = new QLabel(this);
//   labVs->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
  labVs->setIndent(indentVal);
  labVs->setText("");
  setAddStrVs("");
  setVs(0);

  itemVs = new QTreeWidgetItem();
  itemVs->setSizeHint(0, QSize(100, sizeVCell));

  toolTip = "Незаиляющая скорость";

  itemVs->setToolTip(0, toolTip);
  itemVs->setToolTip(1, toolTip);

//vr
  strName  = "<font size=";
  strName += QString().setNum(sizeText);
  strName += ">v<sub><font size=";
  strName += QString().setNum(sizeSub);
  strName += ">r</sub></font>";

  nameVr = new QLabel();
  nameVr->setOpenExternalLinks(false);
  nameVr->setTextInteractionFlags(Qt::NoTextInteraction);
  nameVr->setText(strName);
  nameVr->setIndent(indentVar);

  labVr = new QLabel(this);
//   labVr->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
  labVr->setIndent(indentVal);
  labVr->setText("");
  setAddStrVr("");
  setVr(0);

  itemVr = new QTreeWidgetItem();
  itemVr->setSizeHint(0, QSize(100, sizeVCell));

  toolTip = "Расчетная скорость";

  itemVr->setToolTip(0, toolTip);
  itemVr->setToolTip(1, toolTip);

//vd
  strName  = "<font size=";
  strName += QString().setNum(sizeText);
  strName += ">v<sub><font size=";
  strName += QString().setNum(sizeSub);
  strName += ">d</sub></font>";

  nameVd = new QLabel();
  nameVd->setOpenExternalLinks(false);
  nameVd->setTextInteractionFlags(Qt::NoTextInteraction);
  nameVd->setText(strName);
  nameVd->setIndent(indentVar);

  labVd = new QLabel(this);
//   labVd->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
  labVd->setIndent(indentVal);
  labVd->setText("");
  setAddStrVd("");
  setVd(0);

  itemVd = new QTreeWidgetItem();
  itemVd->setSizeHint(0, QSize(100, sizeVCell));

  toolTip = "Неразмывающая скорость";

  itemVd->setToolTip(0, toolTip);
  itemVd->setToolTip(1, toolTip);

//Заголовок для расчета скоростей
  strName  = "<font color=#E0E0E0 size=";
  strName += QString().setNum(sizeTextHead);
  strName += "><b>Скорость</b></font>";

  nameResRainWater = new QLabel();
  nameResRainWater->setOpenExternalLinks(false);
  nameResRainWater->setTextInteractionFlags(Qt::NoTextInteraction);
  nameResRainWater->setText(strName);
  nameResRainWater->setIndent(indentVar);

  itemResRainWater = new QTreeWidgetItem();
  itemResRainWater->setSizeHint(0, QSize(100, sizeVCell));
  itemResRainWater->setBackground(0, headBrush);
//   itemResRainWater->setBackground(0, clH0);

  itemResRainWater->addChild(itemVs);
  itemResRainWater->addChild(itemVr);
  itemResRainWater->addChild(itemVd);

  this->addTopLevelItem(itemResRainWater);
  this->setItemWidget(itemResRainWater, 0, nameResRainWater);
  this->setFirstItemColumnSpanned(itemResRainWater, true);

  this->setItemWidget(itemVs, 0, nameVs);
  this->setItemWidget(itemVs, 1, labVs);

  this->setItemWidget(itemVr, 0, nameVr);
  this->setItemWidget(itemVr, 1, labVr);

  this->setItemWidget(itemVd, 0, nameVd);
  this->setItemWidget(itemVd, 1, labVd);

  itemResRainWater->setExpanded(true);

} //Result::Result(QWidget *parent) : QTreeWidget(parent)

double Result::getVal(int varName) {

  switch (varName) {

     case VAR_AREA:	        return insArea;		break;
     case VAR_PERIMETER: 	return insPerimeter; 	break;
     case VAR_RADIUS: 		return insRadius; 	break;
     case VAR_SHEZY: 		return insShezy; 	break;
     case VAR_AQ: 		return insAQ; 		break;
     case VAR_ICR: 		return insIcr; 		break;

     case VAR_VS: 		return insVs; 		break;
     case VAR_VR: 		return insVr; 		break;
     case VAR_VD: 		return insVd; 		break;

     case VAR_QRAINCON: 	return insqRainCon; 	break;
     case VAR_QR: 		return insQr; 		break;
     case VAR_QCR: 		return insQcr; 		break;
     case VAR_QREC: 		return insQrec;		break;

     case VAR_HRAIN: 		return insHrain; 	break;
     case VAR_HCR: 		return insHcr; 		break;
     case VAR_HREC: 		return insHrec;		break;

  } //switch (varName)

  return -1;

} //double Result::getVal(int varName)

void Result::setLab(int varName, const QString & newStr) {

  switch (varName) {

     case VAR_AREA:	        labArea->setText(newStr);	break;
     case VAR_PERIMETER: 	labPerimeter->setText(newStr); 	break;
     case VAR_RADIUS: 		labRadius->setText(newStr); 	break;
     case VAR_SHEZY: 		labShezy->setText(newStr); 	break;
     case VAR_AQ: 		labAQ->setText(newStr); 	break;
     case VAR_ICR: 		labIcr->setText(newStr); 	break;

     case VAR_VS: 		labVs->setText(newStr); 	break;
     case VAR_VR: 		labVr->setText(newStr); 	break;
     case VAR_VD: 		labVd->setText(newStr); 	break;

     case VAR_QRAINCON: 	labqRainCon->setText(newStr); 	break;
     case VAR_QR: 		labQr->setText(newStr); 	break;
     case VAR_QCR: 		labQcr->setText(newStr); 	break;
     case VAR_QREC: 		labQrec->setText(newStr); 	break;

     case VAR_HRAIN: 		labHrain->setText(newStr); 	break;
     case VAR_HCR: 		labHcr->setText(newStr); 	break;
     case VAR_HREC: 		labHrec->setText(newStr); 	break;

  } //switch (varName)

} //void Result::setLab(int varName, const QString & newStr)

void Result::updateVar(int varName) {

  double var = getVal(varName);

  if (var < OUTPREC) var = 0;

  QString str("");

  switch (varName) {

     case VAR_AREA:		str += QString().setNum(toPrec(var), 'g', STRPREC); str += addStrArea; break;
     case VAR_PERIMETER: 	str += QString().setNum(toPrec(var), 'g', STRPREC); str += addStrPerimeter; break;
     case VAR_RADIUS: 		str += QString().setNum(toPrec(var), 'g', STRPREC); str += addStrRadius; break;
     case VAR_SHEZY: 		str += QString().setNum(toPrec(var), 'g', STRPREC); str += addStrShezy; break;
     case VAR_AQ: 		str += QString().setNum(toPrec(var), 'g', STRPREC); str += addStrAQ; break;
     case VAR_ICR: 		str += QString().setNum(toPrec(var), 'g', STRPREC); str += addStrIcr; break;

     case VAR_VS: 		str += QString().setNum(toPrec(var), 'g', STRPREC); str += addStrVs; break;
     case VAR_VR: 		str += QString().setNum(toPrec(var), 'g', STRPREC); str += addStrVr; break;
     case VAR_VD: 		str += QString().setNum(toPrec(var), 'g', STRPREC); str += addStrVd; break;

     case VAR_QR: 		str += QString().setNum(toPrec(var), 'g', STRPREC); str += addStrQr; break;
     case VAR_QRAINCON: 	str += QString().setNum(toPrec(var), 'g', STRPREC); str += addStrRainCon; break;
     case VAR_QCR: 		str += QString().setNum(toPrec(var), 'g', STRPREC); str += addStrQcr; break;
     case VAR_QREC: 		str += QString().setNum(toPrec(var), 'g', STRPREC); str += addStrQrec; break;

     case VAR_HRAIN: 		str += QString().setNum(toPrec(var), 'g', STRPREC); str += addStrHrain; break;
     case VAR_HCR: 		str += QString().setNum(toPrec(var), 'g', STRPREC); str += addStrHcr; break;
     case VAR_HREC: 		str += QString().setNum(toPrec(var), 'g', STRPREC); str += addStrHrec; break;

  } //switch (varName)

  setLab(varName, str);

} //void Result::updateVar(int varName)
